﻿using RoboContainer.Core;
using log4net;
using TimeMachine.Engine.Metrics;

namespace TimeMachine.Engine.Agents
{
	public class MeasurementsAgent
	{
		private static readonly ILog log = LogManager.GetLogger(typeof (MeasurementsAgent));
		private readonly Container container;
		private readonly IProjectSettings projectSettings;

		public MeasurementsAgent(IProjectSettings projectSettings)
		{
			this.projectSettings = projectSettings;
			container = new Container(c => c.ForPlugin<IProjectSettings>().UseInstance(projectSettings));
		}

		public void Run()
		{
			log.InfoFormat("Начинаем расчет метрик для {0}", projectSettings.VcsRepo.Url);
			container.Get<IMetricsDriver>().Drive();
			log.InfoFormat("Расчет метрик закончен");
		}
	}
}